home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / alien-neon-logo.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  6.9 KB  |  176 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; alien-neon-logo.scm - creates multiple outlines around the letters
  4. ; Copyright (C) 1999-2000 Raphael Quinet <quinet@gamers.org>
  5. ;
  6. ; This program is free software; you can redistribute it and/or modify
  7. ; it under the terms of the GNU General Public License as published by
  8. ; the Free Software Foundation; either version 2 of the License, or
  9. ; (at your option) any later version.
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ; GNU General Public License for more details.
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ;
  18. ; 1999-12-01 First version.
  19. ; 2000-02-19 Do not discard the layer mask so that it can still be edited.
  20. ; 2000-03-08 Adapted the script to my gimp-edit-fill changes.
  21. ; 2000-04-02 Split the script in two parts: one using text, one using alpha.
  22. ; 2000-05-29 More modifications for "Alpha to Logo" using a separate function.
  23. ;
  24. ; To do: use a channel mask for creating the bands, instead of working in the
  25. ; image.  gimp-invert would then work on one grayscale channel instead of
  26. ; wasting CPU cycles on three identical R, G, B channels.
  27.  
  28. (define (apply-alien-neon-logo-effect img
  29.                       logo-layer
  30.                       fg-color
  31.                       bg-color 
  32.                       band-size 
  33.                       gap-size 
  34.                       num-bands 
  35.                       do-fade)
  36.   (let* ((fade-size (- (* (+ band-size gap-size) num-bands) 1))
  37.      (width (car (gimp-drawable-width logo-layer)))
  38.      (height (car (gimp-drawable-height logo-layer)))
  39.      (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
  40.      (bands-layer (car (gimp-layer-new img width height RGBA-IMAGE "Bands" 100 NORMAL-MODE))))
  41.  
  42.     (gimp-context-push)
  43.  
  44.     (script-fu-util-image-resize-from-layer img logo-layer)
  45.     (gimp-image-add-layer img bg-layer 1)
  46.     (gimp-image-add-layer img bands-layer 1)
  47.     (gimp-selection-none img)
  48.     (gimp-context-set-background bg-color)
  49.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  50.     (gimp-context-set-background '(0 0 0))
  51.     (gimp-edit-fill bands-layer BACKGROUND-FILL)
  52.     ; The text layer is never shown: it is only used to create a selection
  53.     (gimp-selection-layer-alpha logo-layer)
  54.     (gimp-context-set-foreground '(255 255 255))
  55.     (gimp-edit-fill bands-layer FOREGROUND-FILL)
  56.  
  57.     ; Create multiple outlines by growing and inverting the selection
  58.     ; The bands are black and white because they will be used as a mask.
  59.     (while (> num-bands 0)
  60.        (gimp-selection-grow img band-size)
  61.        (gimp-invert bands-layer)
  62.        (gimp-selection-grow img gap-size)
  63.        (gimp-invert bands-layer)
  64.        (set! num-bands (- num-bands 1)))
  65.  
  66.     ; The fading effect is obtained by masking the image with a gradient.
  67.     ; The gradient is created by filling a bordered selection (white->black).
  68.     (if (= do-fade TRUE)
  69.     (let ((bands-layer-mask (car (gimp-layer-create-mask bands-layer
  70.                                  ADD-BLACK-MASK))))
  71.       (gimp-layer-add-mask bands-layer bands-layer-mask)
  72.       (gimp-selection-layer-alpha logo-layer)
  73.       (gimp-selection-border img fade-size)
  74.       (gimp-edit-fill bands-layer-mask FOREGROUND-FILL)
  75.       (gimp-layer-remove-mask bands-layer MASK-APPLY)))
  76.  
  77.     ; Transfer the resulting grayscale bands into the layer mask.
  78.     (let ((bands-layer-mask (car (gimp-layer-create-mask bands-layer
  79.                              ADD-BLACK-MASK))))
  80.       (gimp-layer-add-mask bands-layer bands-layer-mask)
  81.       (gimp-selection-none img)
  82.       (gimp-edit-copy bands-layer)
  83.       (gimp-floating-sel-anchor (car (gimp-edit-paste bands-layer-mask
  84.                               FALSE))))
  85.  
  86.     ; Fill the layer with the foreground color.  The areas that are not
  87.     ; masked become visible.
  88.     (gimp-context-set-foreground fg-color)
  89.     (gimp-edit-fill bands-layer FOREGROUND-FILL)
  90.     ;; (gimp-layer-remove-mask bands-layer MASK-APPLY)
  91.  
  92.     ; Clean up and exit.
  93.     (gimp-drawable-set-visible logo-layer 0)
  94.     (gimp-image-set-active-layer img bands-layer)
  95.     (gimp-displays-flush)
  96.     
  97.     (gimp-context-pop)))
  98.  
  99. (define (script-fu-alien-neon-logo-alpha img
  100.                      logo-layer
  101.                      fg-color
  102.                      bg-color
  103.                      band-size
  104.                      gap-size
  105.                      num-bands
  106.                      do-fade)
  107.   (begin
  108.     (gimp-image-undo-group-start img)
  109.     (apply-alien-neon-logo-effect img logo-layer fg-color bg-color 
  110.                   band-size gap-size num-bands do-fade)
  111.     (gimp-image-undo-group-end img)
  112.     (gimp-displays-flush)))
  113.  
  114. (script-fu-register "script-fu-alien-neon-logo-alpha"
  115.             _"Alien _Neon..."
  116.             "Creates a psychedelic effect with outlines of the specified color around the letters"
  117.             "Raphael Quinet (quinet@gamers.org)"
  118.             "Raphael Quinet"
  119.             "1999-2000"
  120.             "RGBA"
  121.                     SF-IMAGE      "Image"             0
  122.                     SF-DRAWABLE   "Drawable"          0
  123.             SF-COLOR      _"Glow color"       '(0 255 0)
  124.             SF-COLOR      _"Background color" '(0 0 0)
  125.                     SF-ADJUSTMENT _"Width of bands"   '(2 1 60 1 10 0 0)
  126.                     SF-ADJUSTMENT _"Width of gaps"    '(2 1 60 1 10 0 0)
  127.                     SF-ADJUSTMENT _"Number of bands"  '(7 1 100 1 10 0 1)
  128.             SF-TOGGLE     _"Fade away"        TRUE)
  129.  
  130. (script-fu-menu-register "script-fu-alien-neon-logo-alpha"
  131.              _"<Image>/Script-Fu/Alpha to Logo")
  132.  
  133.  
  134. (define (script-fu-alien-neon-logo text 
  135.                    size 
  136.                    fontname 
  137.                    fg-color 
  138.                    bg-color 
  139.                    band-size 
  140.                    gap-size 
  141.                    num-bands 
  142.                    do-fade)
  143.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  144.      (fade-size (- (* (+ band-size gap-size) num-bands) 1))
  145.      (text-layer (car (gimp-text-fontname img -1 0 0 text (+ fade-size 10) TRUE size PIXELS fontname))))
  146.     (gimp-image-undo-disable img)
  147.     (gimp-drawable-set-name text-layer text)
  148.     (apply-alien-neon-logo-effect img text-layer fg-color bg-color
  149.                   band-size gap-size num-bands do-fade)
  150.     (gimp-image-undo-enable img)
  151.     (gimp-display-new img)))
  152.  
  153. (script-fu-register "script-fu-alien-neon-logo"
  154.             _"Alien _Neon..."
  155.             "Creates a psychedelic effect with outlines of the specified color around the letters"
  156.             "Raphael Quinet (quinet@gamers.org)"
  157.             "Raphael Quinet"
  158.             "1999-2000"
  159.             ""
  160.             SF-STRING     _"Text"               "The GIMP"
  161.             SF-ADJUSTMENT _"Font size (pixels)" '(150 2 1000 1 10 0 1)
  162.             SF-FONT       _"Font"               "Blippo"
  163.             SF-COLOR      _"Glow color"         '(0 255 0)
  164.             SF-COLOR      _"Background color"   '(0 0 0)
  165.                     SF-ADJUSTMENT _"Width of bands"     '(2 1 60 1 10 0 0)
  166.                     SF-ADJUSTMENT _"Width of gaps"      '(2 1 60 1 10 0 0)
  167.                     SF-ADJUSTMENT _"Number of bands"    '(7 1 100 1 10 0 1)
  168.             SF-TOGGLE     _"Fade away"          TRUE)
  169.  
  170. (script-fu-menu-register "script-fu-alien-neon-logo"
  171.              _"<Toolbox>/Xtns/Script-Fu/Logos")
  172.